import com.mihu.www.Coder;
import com.mihu.www.HelloWorld;
import com.mihu.www.Producer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

@Configuration
@ComponentScan(value = "com.mihu.www")
public class AppConfig2 {
  @Bean(name="helloWorld")
  public HelloWorld helloWorld(){
    return new HelloWorld();
  }
  @Bean(name="goodCoder")
  @Scope("singleton")
  public Coder goodCoder(){
    return new Coder("nice code");
  }
  @Bean
  public Producer producer(){
    Producer producer = new Producer();
    producer.setCoder(goodCoder());
    return producer;
  }
}
